@model T2.WebSecurity.ASPMVC.ViewModel.MembershipViewModel
@using T2.WebSecurity.ASPMVC.Entity.Interface          
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>@Model.Title</title>
</head>
<body>
	<script type="text/javascript">
	    jQuery(document).ready(function() {
	        var options = {
	            beforeSubmit: validate,  // pre-submit callback
	            success: showResponse  // post-submit callback 
	           
	        };

	        // bind form using 'ajaxForm' 
	        $('#updatemembership').ajaxForm(options);
	       	$('#output1').hide();
	        $('#message').hide();
	        function validate(formData, jqForm, options) {
	           var form = jqForm[0];
	           var myList = $('#output1');
			   myList.empty();
				 if (isEmpty(form.ConfirmationToken.value)) {
				myList.append("<li>Please enter a value for Confirmation Token.</li>");
				};
				 if (isEmpty(form.IsConfirmed.value)) {
				myList.append("<li>Please enter a value for Is Confirmed.</li>");
				};
				 if (!isDate(form.LastPasswordFailureDate.value)) {
				myList.append("<li>Please enter a date for Last Password Failure Date.</li>");
				};
				 if (!isNumeric(form.PasswordFailuresSinceLastSuccess.value)) {
				myList.append("<li>Please enter a number for Password Failures Since Last Success.</li>");
				};
				 if (isEmpty(form.Password.value)) {
				myList.append("<li>Please enter a value for Password.</li>");
				};
				 if (!isDate(form.PasswordChangedDate.value)) {
				myList.append("<li>Please enter a date for Password Changed Date.</li>");
				};
				 if (isEmpty(form.PasswordSalt.value)) {
				myList.append("<li>Please enter a value for Password Salt.</li>");
				};
				 if (isEmpty(form.PasswordVerificationToken.value)) {
				myList.append("<li>Please enter a value for Password Verification Token.</li>");
				};
				 if (!isDate(form.PasswordVerificationTokenExpirationDate.value)) {
				myList.append("<li>Please enter a date for Password Verification Token Expiration Date.</li>");
				};
				 if (isEmpty(form.EmailAccount.value)) {
				myList.append("<li>Please enter a value for Email Account.</li>");
				};
				 if (isEmpty(form.PasswordAnswer.value)) {
				myList.append("<li>Please enter a value for Password Answer.</li>");
				};
				 if (!isDate(form.LastLoginDate.value)) {
				myList.append("<li>Please enter a date for Last Login Date.</li>");
				};
				 if (!isDate(form.LastLockoutDate.value)) {
				myList.append("<li>Please enter a date for Last Lockout Date.</li>");
				};
				 if (!isNumeric(form.UserId.value)) {
				myList.append("<li>Please enter a number for User Id.</li>");
				};
				 if (!isNumeric(form.PasswordQuestionID.value)) {
				myList.append("<li>Please enter a number for Password Question I D.</li>");
				};
				 if (isEmpty(form.UserProfile.value)) {
				myList.append("<li>Please enter a value for User Profile.</li>");
				};
				 if (isEmpty(form.PasswordQuestion.value)) {
				myList.append("<li>Please enter a value for Password Question.</li>");
				};
				if(isEmpty(form.ConfirmationToken.value)|| isEmpty(form.IsConfirmed.value)|| !isDate(form.LastPasswordFailureDate.value)|| !isNumeric(form.PasswordFailuresSinceLastSuccess.value)|| isEmpty(form.Password.value)|| !isDate(form.PasswordChangedDate.value)|| isEmpty(form.PasswordSalt.value)|| isEmpty(form.PasswordVerificationToken.value)|| !isDate(form.PasswordVerificationTokenExpirationDate.value)|| isEmpty(form.EmailAccount.value)|| isEmpty(form.PasswordAnswer.value)|| !isDate(form.LastLoginDate.value)|| !isDate(form.LastLockoutDate.value)|| !isNumeric(form.UserId.value)|| !isNumeric(form.PasswordQuestionID.value)|| isEmpty(form.UserProfile.value)|| isEmpty(form.PasswordQuestion.value)){
	                $('#output1').show();
	                $('#message').hide();
	                return false;
	            };

	        };

	       function showResponse(responseText, statusText, xhr, $form) {
	            if (responseText == "true") {
	                $('#message').text("Your update succeeded");
	            }
	            else {
	                $('#message').text("Your update was not successful");
	            }
	            $('#message').show();
	            $('#output1').hide();
	            return true;
	        };

	        function showError(XHRResponse, statusText, error) {

	            if (statusText == "error") {
	                $('#message').text("An error has occured in your application! The error is " + error.toString());
	            }
	            else if (statusText == "timeout") {
	                $('#message').text("The server has timed out! Please try again later.");

	            }
	            else {
	                $('#message').text(error);
	                $('#message').show();
	                $('#output1').hide();
	            }
	            return false;
	        };

	        $('#resetmembership').click(function(event) {
	            $('#updatemembership').clearForm();
				$('#message').hide();
	            $('#output1').hide();
	        });

			$("#LastPasswordFailureDate").datepicker();
				$("#PasswordChangedDate").datepicker();
				$("#PasswordVerificationTokenExpirationDate").datepicker();
				$("#LastLoginDate").datepicker();
				$("#LastLockoutDate").datepicker();
	        $('span.ui-dialog-title').text('Modify Membership');
			$('input:radio').button();
			$('input:submit').button();
	        $('input:button').button();


	    });
	    
	
	</script>

    <div>
	
	
		<ul class="ui-state-error"  id="output1" style="width:400px"></ul>
		<ul id="message" style="width:400px; height:25px; background-color:Blue; color:White"></ul>
    	<form action="./Membership/Update/" id="updatemembership" method="post" name="updatemembership" >
			<div class="formSection ui-widget-content ui-corner-all">
                <div class="ui-widget-header">
			        <span>@Model.Header</span>
		        </div>
<div id="Empty" class="fullSection">
			<div class="">
			<span>Confirmation Token</span>
			<span><input type="text" id="ConfirmationToken" name="ConfirmationToken" value="@Model.Model.ConfirmationToken.ToString()" /></span>
			</div>
			<div class="">
			<span>Is Confirmed</span>
			<span>
			<div class="radio"
			<input type="radio" name="IsConfirmed" id="isconfirmedtrue" value="true" checked="checked" />
			<input type="radio" name="IsConfirmed" id="isconfirmedtrue" value="true" />
			</div>
			/<span>
			</div>
			<div class="">
			<span>Last Password Failure Date</span>
			<span><input type="text" id="LastPasswordFailureDate" name="LastPasswordFailureDate" value="@Model.Model.LastPasswordFailureDate.ToString()" /></span>
			</div>
			<div class="">
			<span>Password Failures Since Last Success</span>
			<span><input type="text" id="PasswordFailuresSinceLastSuccess" name="PasswordFailuresSinceLastSuccess" value="@Model.Model.PasswordFailuresSinceLastSuccess.ToString()" /></span>
			</div>
			<div class="">
			<span>Password</span>
			<span><input type="text" id="Password" name="Password" value="@Model.Model.Password.ToString()" /></span>
			</div>
			<div class="">
			<span>Password Changed Date</span>
			<span><input type="text" id="PasswordChangedDate" name="PasswordChangedDate" value="@Model.Model.PasswordChangedDate.ToString()" /></span>
			</div>
			<div class="">
			<span>Password Salt</span>
			<span><input type="text" id="PasswordSalt" name="PasswordSalt" value="@Model.Model.PasswordSalt.ToString()" /></span>
			</div>
			<div class="">
			<span>Password Verification Token</span>
			<span><input type="text" id="PasswordVerificationToken" name="PasswordVerificationToken" value="@Model.Model.PasswordVerificationToken.ToString()" /></span>
			</div>
			<div class="">
			<span>Password Verification Token Expiration Date</span>
			<span><input type="text" id="PasswordVerificationTokenExpirationDate" name="PasswordVerificationTokenExpirationDate" value="@Model.Model.PasswordVerificationTokenExpirationDate.ToString()" /></span>
			</div>
			<div class="">
			<span>Email Account</span>
			<span><input type="text" id="EmailAccount" name="EmailAccount" value="@Model.Model.EmailAccount.ToString()" /></span>
			</div>
			<div class="">
			<span>Password Answer</span>
			<span><input type="text" id="PasswordAnswer" name="PasswordAnswer" value="@Model.Model.PasswordAnswer.ToString()" /></span>
			</div>
			<div class="">
			<span>Last Login Date</span>
			<span><input type="text" id="LastLoginDate" name="LastLoginDate" value="@Model.Model.LastLoginDate.ToString()" /></span>
			</div>
			<div class="">
			<span>Last Lockout Date</span>
			<span><input type="text" id="LastLockoutDate" name="LastLockoutDate" value="@Model.Model.LastLockoutDate.ToString()" /></span>
			</div>
			<div class="">
			<span>User Id</span>
			<span><input type="text" id="UserId" name="UserId" value="@Model.Model.UserId.ToString()" /></span>
			</div>
			<div class="">
			<span>Password Question I D</span>
			<span><input type="text" id="PasswordQuestionID" name="PasswordQuestionID" value="@Model.Model.PasswordQuestionID.ToString()" /></span>
			</div>
			<div class="">
			<span>User Profile</span>
			<span>
			<select  id='UserProfileID' name='UserProfileID'>
			@foreach (IUserProfile_ui item in Model.UserProfile_List)
			{
			if (Model.Model.UserId == item.UserId)
			{
			<option label="@item.UserId.ToString()" selected="selected" value="@item.UserId.ToString()" >@item.UserId.ToString()</option>
			}
			else
			{
			<option label="@item.UserId.ToString()" value="@item.UserId.ToString()" >@item.UserId.ToString()</option>
			}
			}
			</select>
			</span>
			</div>
			<div class="">
			<span>Password Question</span>
			<span>
			<select  id='PasswordQuestionID' name='PasswordQuestionID'>
			@foreach (IPasswordQuestion_ui item in Model.PasswordQuestion_List)
			{
			if (Model.Model.PasswordQuestionID == item.PasswordQuestionID)
			{
			<option label="@item.PasswordQuestionID.ToString()" selected="selected" value="@item.PasswordQuestionID.ToString()" >@item.PasswordQuestionID.ToString()</option>
			}
			else
			{
			<option label="@item.PasswordQuestionID.ToString()" value="@item.PasswordQuestionID.ToString()" >@item.PasswordQuestionID.ToString()</option>
			}
			}
			</select>
			</span>
			</div>
			</div>
			<div class="fullSection">
			<span><input id="submitmembership" type="submit" value="Submit" /><input id="resetmembership" type="button" value="Reset" /></span>
			</div>
			
			</div>
        </div>
		</form>
    
</body>
</html>